/*
 * Copyright (c) 2020 solidwang. All rights reserved.
 */

package com.solidwang.mybatis.service;

import com.solidwang.mybatis.mapper.UserMapper;
import com.solidwang.mybatis.model.User;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;

@Service
public class UserService {

    @Autowired
    private UserMapper userMapper;

    /**
     * 查找用户
     * @param id
     * @return
     */
    public User findById(Integer id) {

        return userMapper.findById(id);
    }

    /**
     * 保存用户
     * @param name
     * @param age
     * @param ctime
     * @param utime
     * @return
     */
    public int insert(String name, Integer age, Date ctime, Date utime) {

        return userMapper.insert(name, age, ctime, utime);
    }

    /**
     * 更新用户
     * @param id
     * @param name
     */
    public void updataById(Integer id, String name) {

        userMapper.updataById(id, name);
    }

    /**
     * 删除用户
     * @param id
     */
    public void deleteById(Integer id) {

        userMapper.deleteById(id);
    }

    /**
     * 查找所有用户
     * @return
     */
    public List<User> findAllUser() {

        return userMapper.findAllUser();
    }
}
